package com.prabhat.webapp.validate;

import java.util.Iterator;
import java.util.List;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;



public class IsUniqueUserImpl implements ConstraintValidator<IsUniqueUser, String>, ApplicationContextAware {
	
	private static final Logger	logger	= LoggerFactory.getLogger(IsUniqueUserImpl.class);
	private String			TAG		= getClass().getName();
	private IsUniqueUser		isUniqueUser;
	private ApplicationContext	ctx;
	
	@Override
	public void initialize(IsUniqueUser constraintAnnotation) {
		this.isUniqueUser = constraintAnnotation;
	}
	
	@Override
	public boolean isValid(String value, ConstraintValidatorContext context) {
		try {
/*			ValidationAttributes attr = ExtendedValidatationAdaptor.getValidationAttributes();
			String uniqueUserAttr = isUniqueUser.uniqueAttributeName();
			Object uniqAttrName = attr.digest().getTargetObjectAttribute(uniqueUserAttr);
			
			if ("emailId".equalsIgnoreCase(uniqueUserAttr)) {
				
			}
*/		} catch (Exception e) {
			logger.error(TAG, e.getMessage());
		}
		return false;
	}
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		ctx = applicationContext;
		
	}
	
}
